package com.msw.design.proxy.cglib;

import net.sf.cglib.proxy.Enhancer;

/**
 * Created by minshiwu on 2017/6/4.
 */
public class Client {

    /**
     * cglib 实现动态代理
     *
     * @param args
     */
    public static void main(String[] args) {
        Programmer programmer = new Programmer();

        Hacker hacker = new Hacker();

        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(programmer.getClass());
        enhancer.setCallback(hacker);

        Programmer proxy = (Programmer) enhancer.create();
        System.err.println(proxy.getClass().getTypeName());


        proxy.code("hell,world");
        proxy.write("doc", "ppt");

    }
}
